package com.stan.core.mapper;

import com.stan.core.vo.AdTopNProvinceDailyCount;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 广告每天各省topN信息Mapper
 */
@Mapper
public interface AdTopNProvinceDailyCountMapper {

    /**
     * 插入对象
     * @param adTopNProvinceDailyCount
     */
    @Insert("insert into t_ad_top10_province_count (date,province,rank,aid,click_count) values " +
            "(#{date},#{province},#{rank},#{aid},#{clickCount})")
    void insert(AdTopNProvinceDailyCount adTopNProvinceDailyCount);


    /**
     * 更新对象
     * @param adTopNProvinceDailyCount
     */
    @Update("update t_ad_top10_province_count set aid=#{aid},click_count=#{clickCount} " +
            "where date=#{date} and province=#{province} and rank=#{rank}")
    void update(AdTopNProvinceDailyCount adTopNProvinceDailyCount);


    /**
     * 获得记录
     * @param adTopNProvinceDailyCount
     * @return
     */
    @Select("select date,province,rank,aid,click_count as clickCount from t_ad_top10_province_count " +
            "where date=#{date} and province=#{province} and rank=#{rank} " +
            "limit 1")
    AdTopNProvinceDailyCount getOne(AdTopNProvinceDailyCount adTopNProvinceDailyCount);



}
